package com.fetchdata.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fetchdata.entity.InvestFirm;
import com.song.user.mapper.UserMapper;

import basic.commons.util.UUIDFactory;


@Service
@Transactional
public class BookService {
	@Autowired
	MongoTemplate mongoTemplate;
	@Autowired
	UserMapper userMapper;
	
	public void data(){
		List<Map> findAll = mongoTemplate.findAll(Map.class,"kr36_organizations");
		
		List<InvestFirm> tempMap=new ArrayList<>();
		
		for(Map map:findAll){
			InvestFirm obj=new InvestFirm();
			obj.setZj(UUIDFactory.getUUIDStr());
			obj.setFirmName((String)map.get("name"));
			obj.setFirmNickName((String)map.get("nameAbbr"));
			tempMap.add(obj);
		}
		userMapper.insertInvestfirmAll(tempMap);
	}
	
}
